<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>ajax</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<script type="text/javascript" src="../../statics/common/js/header.js"></script>
		<!--标准mdui.css-->
		<link rel="stylesheet" href="../../statics/mdui/css/mdui.min.css">
		<!--App自定义的css-->
		<link rel="stylesheet" type="text/css" href="../../statics/mdui/css/app.css"/>
		<style>
		 	.mui-content-padded {
				padding: 10px;
			}
			body,body .mui-content {
				background-color: #fff !important;
			}
			code {
				word-wrap: break-word;
				word-break: normal;
				font-size: 90%;
				color: #c7254e;
				background-color: #f9f2f4;
				border-radius: 4px;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">ajax（网络请求）</h1>
		</header>
		<div class="mui-content">
			<div class="mui-content-padded" style="padding-bottom: 50px;">
				<p style="text-indent: 22px;">
					mui基于html5plus的<a href="http://www.dcloud.io/docs/api/zh_cn/xhr.shtml">XMLHttpRequest</a>，封装了常用的ajax函数，支持Get、Post请求方式， 支持返回json、xml、html、text、script数据类型；本示例使用<a href="http://www.oschina.net/question/82993_78609">RunJS</a>的Echo Ajax功能演示网络请求。
				</p>
				<h4 class="mui-content-padded">发送请求：</h4>
				<div class="mui-input-group">
					<div class="mui-input-row">
						<label>type:</label>
						<select id="method">
							<option value="get">GET</option>
							<option value="post">POST</option>
						</select>
					</div>
					<div class="mui-input-row">
						<label>dataType:</label>
						<select id="dataType">
							<option value="json">JSON</option>
						</select>
					</div>
					<div class="mui-button-row">
						<button type="button" id="confirm" class="mui-btn mui-btn-primary"  onclick="doAjax()">发送请求</button>
					</div>
				</div>
				<h4 class="mui-content-padded">获得响应：</h4>
				<code id="response"></code>
			</div>
		</div>
		<script src="../../statics/mdui/js/mdui.min.js"></script>
		<script type="text/javascript" src="../../statics/common/js/mdlife.js"></script>
		<script type="text/javascript" src="../../statics/common/js/common.js"></script>
		<script type="text/javascript">
			mdui.init({
				swipeBack:true //启用右滑关闭功能
			});
			function doAjax() {
				Base.requestServer("test", {}, function(data) {
					$("code").html(Base.jsonToStr(data));
				}, true, "get");
			}
		</script>
	</body>

</html>